var e = require;
var t = module;
var n = exports;
var o =
        (this && this.__awaiter) ||
        function (e, a, s, c) {
            return new (s = s || Promise)(function (n, t) {
                function o(e) {
                    try {
                        r(c.next(e));
                    } catch (e) {
                        t(e);
                    }
                }
                function i(e) {
                    try {
                        r(c.throw(e));
                    } catch (e) {
                        t(e);
                    }
                }
                function r(e) {
                    var t;
                    e.done
                        ? n(e.value)
                        : ((t = e.value) instanceof s
                              ? t
                              : new s(function (e) {
                                    e(t);
                                })
                          ).then(o, i);
                }
                r((c = c.apply(e, a || [])).next());
            });
        },
    c =
        (this && this.__generator) ||
        function (n, o) {
            var i,
                r,
                a,
                s = {
                    label: 0,
                    sent: function () {
                        if (1 & a[0]) throw a[1];
                        return a[1];
                    },
                    trys: [],
                    ops: []
                },
                e = {next: t(0), throw: t(1), return: t(2)};
            return (
                "function" == typeof Symbol &&
                    (e[Symbol.iterator] = function () {
                        return this;
                    }),
                e
            );
            function t(t) {
                return function (e) {
                    return (function (t) {
                        if (i) throw new TypeError("Generator is already executing.");
                        for (; s; )
                            try {
                                if (
                                    ((i = 1),
                                    r &&
                                        (a =
                                            2 & t[0]
                                                ? r.return
                                                : t[0]
                                                ? r.throw || ((a = r.return) && a.call(r), 0)
                                                : r.next) &&
                                        !(a = a.call(r, t[1])).done)
                                )
                                    return a;
                                switch (((r = 0), (t = a ? [2 & t[0], a.value] : t)[0])) {
                                    case 0:
                                    case 1:
                                        a = t;
                                        break;
                                    case 4:
                                        return s.label++, {value: t[1], done: !1};
                                    case 5:
                                        s.label++, (r = t[1]), (t = [0]);
                                        continue;
                                    case 7:
                                        (t = s.ops.pop()), s.trys.pop();
                                        continue;
                                    default:
                                        if (
                                            !(a = 0 < (a = s.trys).length && a[a.length - 1]) &&
                                            (6 === t[0] || 2 === t[0])
                                        ) {
                                            s = 0;
                                            continue;
                                        }
                                        if (3 === t[0] && (!a || (t[1] > a[0] && t[1] < a[3]))) {
                                            s.label = t[1];
                                            break;
                                        }
                                        if (6 === t[0] && s.label < a[1]) {
                                            (s.label = a[1]), (a = t);
                                            break;
                                        }
                                        if (a && s.label < a[2]) {
                                            (s.label = a[2]), s.ops.push(t);
                                            break;
                                        }
                                        a[2] && s.ops.pop(), s.trys.pop();
                                        continue;
                                }
                                t = o.call(n, s);
                            } catch (e) {
                                (t = [6, e]), (r = 0);
                            } finally {
                                i = a = 0;
                            }
                        if (5 & t[0]) throw t[1];
                        return {value: t[0] ? t[1] : void 0, done: !0};
                    })([t, e]);
                };
            }
        };
Object.defineProperty(n, "__esModule", {value: !0}), (n.showToast = void 0);
var l = e("resources");
n.showToast = function (a, s) {
    return (
        void 0 === s && (s = 3e3),
        o(this, void 0, void 0, function () {
            var t, n, o, i, r;
            return c(this, function (e) {
                switch (e.label) {
                    case 0:
                        return null == a || "" == a
                            ? [2]
                            : ((t = cc.director.getScene().getComponentInChildren(cc.Canvas)),
                              (o = t.node.getChildByName("Toast")) && o.destroy(),
                              [4, l.loadLocalRes("Texture/common/Text_Background", cc.SpriteFrame)]);
                    case 1:
                        return (
                            (i = e.sent()),
                            ((n = new cc.Node("Toast")).opacity = 0),
                            ((r = new cc.Node("LabelNode")).addComponent(cc.Label).string = a),
                            ((o = n.addComponent(cc.Layout)).resizeMode = cc.Layout.ResizeMode.CONTAINER),
                            (o.paddingLeft = 30),
                            (o.paddingRight = 30),
                            (o.paddingTop = 25),
                            (o.paddingBottom = 20),
                            ((o = n.addComponent(cc.Sprite)).type = cc.Sprite.Type.SLICED),
                            (o.spriteFrame = i),
                            n.addChild(r),
                            t.node.addChild(n),
                            (i = cc.callFunc(function () {
                                cc.tween(n).to(0.3, {opacity: 255}).start();
                            })),
                            (r = cc.callFunc(function () {
                                var e = setTimeout(function () {
                                    n.destroy(), clearTimeout(e);
                                }, s);
                            }, this)),
                            (r = cc.sequence(i, r)),
                            n.runAction(r),
                            [2]
                        );
                }
            });
        })
    );
};
